100 101 102 103 104 105
Statement 1, LET NUM = 100
starts NUM
at 100.
The DO
statement, DO WHILE NUM <= 105
executes loop
body as long as NUM
is less than or equal to 105.
Statement 4, LET NUM = NUM + 1
increases NUM
by one
each time.
You can select the range of integers you want. Say that you want to count up from first to last. For example, if first is 50 and last is 55 you want 50, 51, 52, 53, 54, and 55. Here is how the loop is written:
DO WHILE
statement.
LET
statement
in the loop body.(There are other ways to combine statements in loops than what we have been doing. These three points do not apply to all combinations.)
Here is another change to the program. Think about how it illustrates these three points:
' Loop with a loop condition ' LET NUM = 25 'Statement 1 DO WHILE NUM <= 30 'Statement 2 PRINT NUM 'Statement 3 LET NUM = NUM + 1 'Statement 4 LOOP END
What will this new program print on the monitor screen?